﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MongoDB.Driver;
using MongoDB.Bson;
using MongoDB.Driver.Builders;

namespace MidasPoster
{
    public partial class MP_LoginForm : Form
    {
        
        public MP_LoginForm()
        {
            InitializeComponent();
        }

        private void MP_Login_Form_OK_Button_Click(object sender, EventArgs e)
        {
            DBManager.Singleton.OpenServerUrl(MP_Login_Form_Server_TextBox.Text, MP_Login_Form_Port_TextBox.Text, MP_Login_Form_UserName_TextBox.Text, MP_Login_Form_Password_TextBox.Text);
            if (DBManager.Singleton.GoAuthUser(MP_Login_Form_UserName_TextBox.Text, MP_Login_Form_Password_TextBox.Text,false))
            {
                MP_Login_Form_MSG.Text = MP_Login_Form_UserName_TextBox.Text +"登录成功！";
                
            }
            else
            {
                MP_Login_Form_MSG.Text = MP_Login_Form_UserName_TextBox.Text + "登录失败！";
            }
            //int inewid = DBManager.Singleton.getAutoIndexManager.GetNewIndex(EDBINFOS.EDBINFO_ACOUNT);
            //Close();
        }

        private void MP_Login_Form_Cancel_Button_Click(object sender, EventArgs e)
        {
//             MDTB_ACOUNT acount = new MDTB_ACOUNT();
//             acount.USERNAME = "jash1";
//             acount.PASSWORD = "123";
//             BsonDocument bd = BsonExtensionMethods.ToBsonDocument(acount);
//             WriteConcernResult rsl = _acounts.Insert(bd);
//             MongoDB.Bson.ObjectId _id = bd["_id"].AsObjectId;
//             bool iserr = rsl.HasLastErrorMessage;
            //DBManager.Singleton.QuitSystem();
            Close();
        }

    }
}
